< previous page page_80 next page >

Page 80
LargeChange property. The default setting of the LargeChange property is 1. The setting you use depends on your application. For example, a value of 10 is a good number if you are setting percentages.
tip.gif
A good rule of thumb is to set the LargeChange property to a number about five to ten percent of the total range (for example, a value of 50 for a 0 to 1000 range.)

Showing the User the Numbers
Although the visual representation is nice, users cannot tell what the range is or the exact numeric value. Sometimes you may need to write code to provide more detailed feedback. For example, suppose you are using a scrollbar to browse the letters of the alphabet for a database search. As users move the mouse, you can display the value they are scrolling through and then, when they release the mouse, perform the actual database search (see Figure 4.17).
0080-01.jpg
Figure 4.17
Associating labels or text boxes with the scrollbar
shows the users the range and actual value.
The tricky part is knowing where to put the code statements. To show the value at all times, you actually have to place this statement in three events:
Form_LoadUse this event to display the initial value of the scrollbar after setting up the range.
ChangeThe Change event is triggered when you release the mouse button after dragging the position button to a new location. The Change event is also triggered each time the user clicks one of the arrows or clicks the scrollbar.
ScrollThe Scroll event fires while the scrollbar position button is being dragged. This event allows you to display the value or take action as the Value property changes but before the Change event fires.
To test this alphabet example, create a new Standard EXE project. Place a scrollbar and label on the form. Then enter the code in Listing 4.1.
Listing 4.1 SCRLDEMO.ZIPUsing the Scrollbar
Private Sub Form_Load()
    'Set Max, then Min properties to numeric values
    HScroll1.Max = Asc("Z")
    HScroll1.Min = Asc("A")

    'Display the Initial Value
    Label1.Caption = Chr$(HScroll1.Value)
End Sub

 
< previous page page_80 next page >